using System;
using UnityEngine;

namespace MaterialUI
{
	[Serializable]
	public class ImageData
	{
		[SerializeField]
		private ImageDataType m_ImageDataType;

		[SerializeField]
		private Sprite m_Sprite;

		[SerializeField]
		private VectorImageData m_VectorImageData;

		public ImageDataType imageDataType
		{
			get
			{
				return m_ImageDataType;
			}
			set
			{
				m_ImageDataType = value;
			}
		}

		public Sprite sprite
		{
			get
			{
				return m_Sprite;
			}
			set
			{
				m_Sprite = value;
			}
		}

		public VectorImageData vectorImageData
		{
			get
			{
				return m_VectorImageData;
			}
			set
			{
				m_VectorImageData = value;
			}
		}

		public ImageData(Sprite sprite)
		{
			m_Sprite = sprite;
			m_ImageDataType = ImageDataType.Sprite;
		}

		public ImageData(VectorImageData vectorImageData)
		{
			m_VectorImageData = vectorImageData;
			m_ImageDataType = ImageDataType.VectorImage;
		}

		public bool ContainsData(bool checkCurrentTypeOnly)
		{
			if (checkCurrentTypeOnly)
			{
				if (m_ImageDataType == ImageDataType.Sprite)
				{
					return m_Sprite != null;
				}
				return m_VectorImageData != null && m_VectorImageData.ContainsData();
			}
			return m_Sprite != null || (m_VectorImageData != null && m_VectorImageData.ContainsData());
		}

		public static ImageData[] ArrayFromSpriteArray(Sprite[] spriteArray)
		{
			ImageData[] array = new ImageData[spriteArray.Length];
			for (int i = 0; i < spriteArray.Length; i++)
			{
				array[i] = new ImageData(spriteArray[i]);
			}
			return array;
		}

		public static ImageData[] ArrayFromVectorArray(VectorImageData[] vectorArray)
		{
			ImageData[] array = new ImageData[vectorArray.Length];
			for (int i = 0; i < vectorArray.Length; i++)
			{
				array[i] = new ImageData(vectorArray[i]);
			}
			return array;
		}
	}
}
